#include <string.h>
#include <iostream>
using std::cout;
using std::endl;
class student{
public:
    //构造函数
    student(int ID,int age ,const char * name)
    :_ID(ID)
    ,_age(age)
    ,_name(new char[strlen(name)+1]())
    {
        strcpy(_name,name);
    }
    //拷贝构造函数
    student(const student & rhs)
    :_ID(rhs._ID)
    ,_age(rhs._age)
    ,_name(new char[strlen(rhs._name)+1]())
    {
       strcpy(_name,rhs._name);
    }
    //赋值运算函数
    student& operator = (const student&rhs)
    {
        _ID = rhs._ID;
        _age = rhs._age;
        delete []_name;
        _name = new char[strlen(rhs._name)+1];
        strcpy(_name,rhs._name);
        return *this;
    }
    
    ~student(){
        if(_name){
            delete [] _name;
            _name = nullptr;
        }
    }


    void print(){
        cout<<"_ID:"<<_ID<<"_age:"<<_age<<"_name:"<<_name<<endl;
    }
private:
  int _ID;
  int _age;
  char * _name;
};
void test(){
   student s1(1,18,"zs");
   student s2(2,23,"ls");
   student s3 = s1;
   s1.print();
   s2.print();
   s3.print();
}
int main()
{
    test();
    return 0;
}

